package cn.tannn;

import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.Collector;

/**
 * @author tn
 * @date 2022-02-09 09:58
 */
public class Socker {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        // nc64.exe -L -p 9999 or nc -L -p 9999 (https://eternallybored.org/misc/netcat/)
        DataStreamSource<String> localhost = env.socketTextStream("localhost", 9999);
        localhost.flatMap(new FlatMapFunction<String, String>() {
            @Override
            public void flatMap(String s, Collector<String> collector) throws Exception {
                collector.collect(s);
            }
        });
        localhost.print();
        env.execute("Fraud Detection");
    }
}
